package com.company.zhishidian.xuliehua;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * socket 网络序列化
 * 注意：
 * 1.传递的对象必须实现Serializable标记接口，实现对象的可序列化。
 * 2.发送和接收的对象包名应该保持一致，否则会出现java.lang.ClassNotFoundException的异常！
 *
 */
public class Server2 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ServerSocket server = new ServerSocket(8888);
        System.out.println("服务端已启动");
        Socket socket = server.accept();
        ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
        Students s = (Students)ois.readObject();

        System.out.println(s);
    }
}
